package com.xuyuan.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StringUtilTest {
    public static void main(String[] args) {
        String a = "123";
        String b = "234";
        List<String> list = Arrays.asList(a, b);
        System.out.println(a.compareTo(b));
        System.out.println(String.join("\n", list));
        // ArrayList<Object> list1 = null;
        // for (Object o : list1) {
        //     System.out.println(o);
        // }
        List<String> collect = list.stream().peek(x -> x = "1111").collect(Collectors.toList());
        System.out.println(collect);

        Man aaa = new Man("aaa", 1);
        Man bbb = new Man("bbb", 1);
        List<Man> list2 = Arrays.asList(aaa, bbb);
        list2.stream().peek(x -> x.setName("xxxx")).collect(Collectors.toList());
        System.out.println(list2);
        // Strem流一定要有消费动作，不然流式处理不生效。因为Stream操作是延迟的，他们会等到需要的结果时才执行。

    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    static class Man {
        private String name;
        private int age;
    }
}
